package com.at713.activiti.lisener;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/11/7 20:46
 */
public class GroupListener implements TaskListener {
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    @Override
    public void notify(DelegateTask delegateTask) {
        //获取流程id
        String exId = delegateTask.getExecutionId();

        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
        RuntimeService runtimeService = engine.getRuntimeService();

        Integer all = (Integer) runtimeService.getVariable(exId, "nrOfInstances");
        Integer complete = (Integer) runtimeService.getVariable(exId, "nrOfCompletedInstances");
        System.out.println("会签完成实例数：" + (complete + 1));
        System.out.println("会签总实例数：" + all);
    }

}
